<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.5"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>SWM34S_LVGL7.11_SWMUI: C:/Users/DELL/Desktop/Commit/lvgl/SWM34S_LVGL7.11_SWMUI_20230515/APP/BSP/dev_sfc.c 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">SWM34S_LVGL7.11_SWMUI<span id="projectnumber">&#160;V7.9</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.5 -->
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_0ca16891106f5a3e9ad635a0d6c5f98f.html">APP</a></li><li class="navelem"><a class="el" href="dir_4ca18d753a70f6eada20fde478bd3fc8.html">BSP</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle"><div class="title">dev_sfc.c</div></div>
</div><!--header-->
<div class="contents">
<a href="dev__sfc_8c.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span> </div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno">   40</span><span class="preprocessor">#include &quot;<a class="code" href="dev__sfc_8h.html">dev_sfc.h</a>&quot;</span></div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno">   41</span> </div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"><a class="line" href="dev__sfc_8c.html#a3e07babe174017b09f2d82c4951172c8">   45</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="dev__sfc_8c.html#a3e07babe174017b09f2d82c4951172c8">sfc_port_init</a>(<span class="keywordtype">void</span>)</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno">   46</span>{</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno">   47</span>    <span class="comment">/* SFC 使用专用的 FSPI(Flash SPI)接口连接 SPI FLASH */</span></div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno">   48</span>    PORT_Init(PORTD, PIN5, PORTD_PIN5_FSPI_SCLK, 0);</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno">   49</span>    PORT_Init(PORTD, PIN6, PORTD_PIN6_FSPI_SSEL, 0);</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno">   50</span>    PORT_Init(PORTD, PIN8, PORTD_PIN8_FSPI_MOSI, 1);</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno">   51</span>    PORT_Init(PORTD, PIN7, PORTD_PIN7_FSPI_MISO, 1);</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno">   52</span>    PORT_Init(PORTD, PIN3, PORTD_PIN3_FSPI_DATA2, 1);</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno">   53</span>    PORT_Init(PORTD, PIN4, PORTD_PIN4_FSPI_DATA3, 1);</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno">   54</span>}</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno">   55</span> </div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"><a class="line" href="dev__sfc_8c.html#aaa274c7312ab8789f8ad8f2feb6075dd">   61</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="dev__sfc_8c.html#aaa274c7312ab8789f8ad8f2feb6075dd">sfc_config</a>(uint8_t width)</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno">   62</span>{</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span>    <a class="code hl_function" href="dev__sfc_8c.html#a3e07babe174017b09f2d82c4951172c8">sfc_port_init</a>();</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno">   64</span> </div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno">   65</span>    SFC_InitStructure SFC_initStruct;</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno">   66</span> </div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno">   67</span>    <span class="keywordflow">switch</span> (width)</div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno">   68</span>    {</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno">   69</span>    <span class="keywordflow">default</span>:</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno">   70</span>        <span class="comment">//break;//continues</span></div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno">   71</span>    <span class="keywordflow">case</span> 1:</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno">   72</span>        SFC_initStruct.ClkDiv = SFC_CLKDIV_2;</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno">   73</span>        SFC_initStruct.Cmd_Read = 0x03;</div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno">   74</span>        SFC_initStruct.Width_Read = SFC_RDWIDTH_1;</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno">   75</span>        SFC_initStruct.Cmd_PageProgram = 0x02;</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno">   76</span>        SFC_initStruct.Width_PageProgram = SFC_PPWIDTH_1;</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno">   77</span>        <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno">   78</span> </div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno">   79</span>    <span class="keywordflow">case</span> 2:</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno">   80</span>        SFC_initStruct.ClkDiv = SFC_CLKDIV_2;</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno">   81</span>        SFC_initStruct.Cmd_Read = 0xBB;</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno">   82</span>        SFC_initStruct.Width_Read = SFC_RDWIDTH_2;</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno">   83</span>        SFC_initStruct.Cmd_PageProgram = 0x02;</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno">   84</span>        SFC_initStruct.Width_PageProgram = SFC_PPWIDTH_1;</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno">   85</span>        <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno">   86</span> </div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno">   87</span>    <span class="keywordflow">case</span> 4: <span class="comment">/* 开启 SPI-Flash 的 Quad SPI Mode(须查看对应型号 spi-flash 是否支持 Quad SPI, 且开启指令/时序是否与驱动库内使用的一致) */</span></div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno">   88</span>        SFC_initStruct.ClkDiv = SFC_CLKDIV_2;</div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno">   89</span>        SFC_initStruct.Cmd_Read = 0xEB;</div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno">   90</span>        SFC_initStruct.Width_Read = SFC_RDWIDTH_4;</div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno">   91</span>        SFC_initStruct.Cmd_PageProgram = 0x32;</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno">   92</span>        SFC_initStruct.Width_PageProgram = SFC_PPWIDTH_4;</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno">   93</span>        <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno">   94</span>    }</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno">   95</span>    SFC_Init(&amp;SFC_initStruct);</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno">   96</span>}</div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno">   97</span> </div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"><a class="line" href="dev__sfc_8c.html#aad5d116153c77313a1212733b556a578">  102</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="dev__sfc_8c.html#aad5d116153c77313a1212733b556a578">sfc_init</a>(<span class="keywordtype">void</span>)</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno">  103</span>{</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno">  104</span>    <a class="code hl_function" href="dev__sfc_8c.html#aaa274c7312ab8789f8ad8f2feb6075dd">sfc_config</a>(4);</div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno">  105</span>}</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno">  106</span> </div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"><a class="line" href="dev__sfc_8c.html#a754be673cc4d49aa9261d43a30c67e00">  113</a></span>uint32_t <a class="code hl_function" href="dev__sfc_8c.html#a754be673cc4d49aa9261d43a30c67e00">sfc_read_id</a>(<span class="keywordtype">void</span>)</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno">  114</span>{</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno">  115</span>    uint32_t result = SFC_ReadJEDEC();</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno">  116</span>    <span class="comment">/* 对 id 做移位处理便于阅读比较 */</span></div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno">  117</span>    <span class="keywordflow">return</span> ( ( ( result &amp; 0xFF ) &lt;&lt; 16 ) | ( ( result &amp; 0xFF00 ) &gt;&gt; 0 ) | ( ( result &amp; 0xFF0000 ) &gt;&gt; 16 ) );</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno">  118</span>}</div>
<div class="ttc" id="adev__sfc_8c_html_a3e07babe174017b09f2d82c4951172c8"><div class="ttname"><a href="dev__sfc_8c.html#a3e07babe174017b09f2d82c4951172c8">sfc_port_init</a></div><div class="ttdeci">void sfc_port_init(void)</div><div class="ttdoc">配置 SFC 专用驱动端口</div><div class="ttdef"><b>Definition:</b> <a href="dev__sfc_8c_source.html#l00045">dev_sfc.c:45</a></div></div>
<div class="ttc" id="adev__sfc_8c_html_a754be673cc4d49aa9261d43a30c67e00"><div class="ttname"><a href="dev__sfc_8c.html#a754be673cc4d49aa9261d43a30c67e00">sfc_read_id</a></div><div class="ttdeci">uint32_t sfc_read_id(void)</div><div class="ttdoc">通过 SFC 读取 SPI-Flash ID</div><div class="ttdef"><b>Definition:</b> <a href="dev__sfc_8c_source.html#l00113">dev_sfc.c:113</a></div></div>
<div class="ttc" id="adev__sfc_8c_html_aaa274c7312ab8789f8ad8f2feb6075dd"><div class="ttname"><a href="dev__sfc_8c.html#aaa274c7312ab8789f8ad8f2feb6075dd">sfc_config</a></div><div class="ttdeci">void sfc_config(uint8_t width)</div><div class="ttdoc">配置 SFC 模块以建立与 SPI-Flash 的通讯</div><div class="ttdef"><b>Definition:</b> <a href="dev__sfc_8c_source.html#l00061">dev_sfc.c:61</a></div></div>
<div class="ttc" id="adev__sfc_8c_html_aad5d116153c77313a1212733b556a578"><div class="ttname"><a href="dev__sfc_8c.html#aad5d116153c77313a1212733b556a578">sfc_init</a></div><div class="ttdeci">void sfc_init(void)</div><div class="ttdoc">初始化 SFC 将 外挂的SPI-Flash 映射至 MCU 总线地址上</div><div class="ttdef"><b>Definition:</b> <a href="dev__sfc_8c_source.html#l00102">dev_sfc.c:102</a></div></div>
<div class="ttc" id="adev__sfc_8h_html"><div class="ttname"><a href="dev__sfc_8h.html">dev_sfc.h</a></div><div class="ttdoc">SPI-Flash Control 硬件专用高速模块</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.5
</small></address>
</body>
</html>
